﻿using Com.Lancetinc.Evs.Events;

namespace Com.Lancetinc.Evs.Models
{
    /// <summary>
    /// 仪器信息
    /// </summary>
    public class GenericInstrumentState : GenericReceivedInstrumentState, IInstrumentState
    {
        public GenericInstrumentState()
        {
            this.Reset();
        }

        public GenericInstrumentState(IInstrumentState instrument) : base(instrument)
        {
            this.InstrumentConnected = instrument.InstrumentConnected;
            this.VideoRecording = instrument.VideoRecording;
        }

        public override void Reset()
        {
            base.Reset();
            this.InstrumentConnected = false;
            this.VideoRecording = false;
        }

        public short GetVideoRotationAngle()
        {
            if (VideoRotate == EnumVideoRotate.R270)
            {
                return 270;
            }
            if (VideoRotate == EnumVideoRotate.R180)
            {
                return 180;
            }
            if (VideoRotate == EnumVideoRotate.R90)
            {
                return 90;
            }
            return 0;
        }

        /// <summary>
        /// 仪器已连接？
        /// </summary>
        public bool InstrumentConnected { get; set; }

        private bool mVideoRecording = false;
        public bool VideoRecording
        {
            get => mVideoRecording;
            set
            {
                if (mVideoRecording != value)
                {
                    mVideoRecording = value;
                    KnownAppEvents.PublishRecordStateChangedEvent(value);
                }
            }
        }
    }
}
